/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * VistaOrden.java
 *
 * Created on 08/04/2011, 01:01:38 AM
 */

package vistas;

import java.awt.event.ActionListener;
import java.util.LinkedList;
import java.util.Vector;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author usuario
 */
public class VistaOrden extends javax.swing.JFrame {

    private controladores.ControladorOrden control;
    private DefaultTableModel modeloTabla;
    private Vector<String> fila;
    /** Creates new form VistaOrden */
    public VistaOrden() {
        initComponents();
        control= new controladores.ControladorOrden(this);

        total.setEditable(false);
    }


     public void addListener(ActionListener escuchador){
        salir.addActionListener(escuchador);
        registrar.addActionListener(escuchador);
        cancelar.addActionListener(escuchador);
        mas.addActionListener(escuchador);
        menos.addActionListener(escuchador);
    }

    public JTable getTblProdcuto() {
        return tblProdcuto;
    }

     
    

    public LinkedList<JTextField> getTextos() {
        LinkedList<JTextField> v = new LinkedList<JTextField>();
        v.add(codigo);
        v.add(cedula);
        v.add(nombre);

        return v;
    }

    public JButton getCancelar() {
        return cancelar;
    }

    public JTextField getCedula() {
        return cedula;
    }

    public JComboBox getCmbCantidad() {
        return cmbCantidad;
    }

    public JComboBox getCmbProducto() {
        return cmbProducto;
    }

    public JTextField getCodigo() {
        return codigo;
    }

    public JButton getMas() {
        return mas;
    }

    public JButton getMenos() {
        return menos;
    }

    public JTextField getNombre() {
        return nombre;
    }

    public JButton getRegistrar() {
        return registrar;
    }

    public JButton getSalir() {
        return salir;
    }

    public JTextField getTotal() {
        return total;
    }  
    

  
    public String getTextoCmbProducto() {
        return (String) cmbProducto.getItemAt(cmbProducto.getSelectedIndex());
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        total = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        codigo = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        nombre = new javax.swing.JTextField();
        cedula = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblProdcuto = new javax.swing.JTable();
        jPanel2 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        cmbProducto = new javax.swing.JComboBox();
        jLabel8 = new javax.swing.JLabel();
        cmbCantidad = new javax.swing.JComboBox();
        mas = new javax.swing.JButton();
        menos = new javax.swing.JButton();
        registrar = new javax.swing.JButton();
        cancelar = new javax.swing.JButton();
        salir = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Registro de  Ordenes");
        getContentPane().setLayout(null);

        total.setFont(new java.awt.Font("Arial", 0, 13)); // NOI18N
        getContentPane().add(total);
        total.setBounds(500, 490, 110, 30);

        jLabel5.setFont(new java.awt.Font("Arial Black", 1, 15)); // NOI18N
        jLabel5.setText("Total:");
        getContentPane().add(jLabel5);
        jLabel5.setBounds(440, 490, 55, 30);

        jPanel1.setBorder(new javax.swing.border.MatteBorder(null));
        jPanel1.setLayout(null);

        jLabel6.setFont(new java.awt.Font("Arial Black", 1, 15)); // NOI18N
        jLabel6.setText("Codigo:");
        jPanel1.add(jLabel6);
        jLabel6.setBounds(20, 10, 100, 30);

        codigo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                codigoActionPerformed(evt);
            }
        });
        jPanel1.add(codigo);
        codigo.setBounds(100, 10, 200, 30);

        jLabel2.setFont(new java.awt.Font("Arial Black", 1, 15)); // NOI18N
        jLabel2.setText("Nombre:");
        jPanel1.add(jLabel2);
        jLabel2.setBounds(20, 90, 140, 32);

        nombre.setFont(new java.awt.Font("Arial", 0, 13));
        jPanel1.add(nombre);
        nombre.setBounds(100, 90, 200, 32);

        cedula.setFont(new java.awt.Font("Arial", 0, 13));
        jPanel1.add(cedula);
        cedula.setBounds(100, 50, 200, 30);

        jLabel3.setFont(new java.awt.Font("Arial Black", 1, 15)); // NOI18N
        jLabel3.setText("Cedula:");
        jPanel1.add(jLabel3);
        jLabel3.setBounds(20, 50, 100, 32);

        getContentPane().add(jPanel1);
        jPanel1.setBounds(80, 30, 380, 150);

        tblProdcuto.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(tblProdcuto);

        getContentPane().add(jScrollPane1);
        jScrollPane1.setBounds(20, 320, 590, 160);

        jPanel2.setBorder(new javax.swing.border.MatteBorder(null));
        jPanel2.setLayout(null);

        jLabel7.setFont(new java.awt.Font("Arial Black", 1, 15)); // NOI18N
        jLabel7.setText("Producto");
        jPanel2.add(jLabel7);
        jLabel7.setBounds(10, 10, 110, 30);

        jPanel2.add(cmbProducto);
        cmbProducto.setBounds(120, 10, 190, 30);

        jLabel8.setFont(new java.awt.Font("Arial Black", 1, 15)); // NOI18N
        jLabel8.setText("Cantidad:");
        jPanel2.add(jLabel8);
        jLabel8.setBounds(10, 60, 100, 30);

        cmbCantidad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbCantidadActionPerformed(evt);
            }
        });
        jPanel2.add(cmbCantidad);
        cmbCantidad.setBounds(120, 60, 190, 30);

        getContentPane().add(jPanel2);
        jPanel2.setBounds(80, 190, 320, 100);

        mas.setFont(new java.awt.Font("Arial Black", 1, 15)); // NOI18N
        mas.setText("+");
        getContentPane().add(mas);
        mas.setBounds(410, 200, 50, 32);

        menos.setFont(new java.awt.Font("Arial Black", 1, 15)); // NOI18N
        menos.setText("-");
        getContentPane().add(menos);
        menos.setBounds(410, 250, 50, 30);

        registrar.setFont(new java.awt.Font("Arial Black", 1, 15)); // NOI18N
        registrar.setText("Registrar");
        registrar.setPreferredSize(new java.awt.Dimension(80, 30));
        getContentPane().add(registrar);
        registrar.setBounds(480, 30, 120, 30);

        cancelar.setFont(new java.awt.Font("Arial Black", 1, 15)); // NOI18N
        cancelar.setText("Cancelar");
        cancelar.setPreferredSize(new java.awt.Dimension(80, 30));
        getContentPane().add(cancelar);
        cancelar.setBounds(480, 80, 120, 30);

        salir.setFont(new java.awt.Font("Arial Black", 1, 15)); // NOI18N
        salir.setText("Salir");
        getContentPane().add(salir);
        salir.setBounds(480, 130, 120, 30);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-629)/2, (screenSize.height-564)/2, 629, 564);
    }// </editor-fold>//GEN-END:initComponents

    private void codigoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_codigoActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_codigoActionPerformed

    private void cmbCantidadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbCantidadActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cmbCantidadActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new VistaOrden().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton cancelar;
    private javax.swing.JTextField cedula;
    private javax.swing.JComboBox cmbCantidad;
    private javax.swing.JComboBox cmbProducto;
    private javax.swing.JTextField codigo;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton mas;
    private javax.swing.JButton menos;
    private javax.swing.JTextField nombre;
    private javax.swing.JButton registrar;
    private javax.swing.JButton salir;
    private javax.swing.JTable tblProdcuto;
    private javax.swing.JTextField total;
    // End of variables declaration//GEN-END:variables

    public String [] getRegistro() {
          String [] s = new String [] {""+cmbProducto.getItemAt(cmbProducto.getSelectedIndex()),""+cmbCantidad.getItemAt(cmbCantidad.getSelectedIndex())};

         return s;
    }



}
